package droid;
//Oi tudo bom
import static robocode.util.Utils.normalRelativeAngleDegrees;

import java.awt.Point;

import robocode.*;

public class DroidSoldier extends AbstractBoot implements Droid {
	/**
	 * run: Droid's default behavior
	 */
	public void run() {
		
		if (pertoParede()) {

			setAhead(60);

		} else {

			ahead(400);
			setTurnRight(angRobAdv);
			descrobreDirecao();
		}

		execute();
	}

	/**
	 * onMessageReceived: What to do when our leader sends a message
	 */
	public void onMessageReceived(MessageEvent e) {
		Pointer p = (Pointer) e.getMessage();
		double dx = p.getX() - this.getX();
		double dy = p.getY() - this.getY();
		// Calculate angle to target
		double theta = Math.toDegrees(Math.atan2(dx, dy));

		// Turn gun to target
		turnGunRight(normalRelativeAngleDegrees(theta - getGunHeading()));
		fogo(50);
		// }
	}
}
